package com.fdb.efp.nls.service.impl;

import com.fdb.basic.framework.core.base.FrameworkService;
import com.fdb.efp.nls.service.dao.GzBankRepayDetailFileTempDao;
import com.fdb.efp.nls.service.domain.GzBankRepayDetailFileTemp;
import com.fdb.efp.nls.service.facade.GzBankRepayDetailFileTempService;
import com.fdb.efp.nls.service.vo.GzBankRepayDetailFileTempVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("gzBankRepayDetailFileTempService")
public class GzBankRepayDetailFileTempServiceImpl implements GzBankRepayDetailFileTempService,FrameworkService {
private static Logger logger = LoggerFactory.getLogger(GzBankRepayDetailFileTempServiceImpl.class);
	
	@Autowired
	private GzBankRepayDetailFileTempDao gzBankRepayDetailFileTempDao;
	
	@Override
	public int insert(GzBankRepayDetailFileTempVO record) {
		GzBankRepayDetailFileTemp gzBankRepayDetailFileTemp=new GzBankRepayDetailFileTemp();
		logger.debug("当前新增数据为:"+ record.toString());
		int num = 0;
		try {			
			beanCopy(record, gzBankRepayDetailFileTemp);
			num = gzBankRepayDetailFileTempDao.insert(gzBankRepayDetailFileTemp);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

	@Override
	public int insertSelective(GzBankRepayDetailFileTempVO record) {
		GzBankRepayDetailFileTemp gzBankRepayDetailFileTemp=new GzBankRepayDetailFileTemp();
		logger.debug("当前新增数据为:"+ record.toString());
		int num = 0;
		try {			
			beanCopy(record, gzBankRepayDetailFileTemp);
			num = gzBankRepayDetailFileTempDao.insert(gzBankRepayDetailFileTemp);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

	@Override
	public List<GzBankRepayDetailFileTempVO> getGzBankRepayDetailFileTempList() {
		logger.debug("当前查询数据信息的参数信息为:");
		List<GzBankRepayDetailFileTempVO> list = null;
		try {			
			List<GzBankRepayDetailFileTemp> gzBankRepayDetailFileTemps = gzBankRepayDetailFileTempDao.getGzBankRepayDetailFileTempList();
			logger.debug("当前查询数据信息的结果集数量为:" + gzBankRepayDetailFileTemps.size());			
			list = (List<GzBankRepayDetailFileTempVO>) beansCopy(gzBankRepayDetailFileTemps, GzBankRepayDetailFileTempVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;
	}

	/**
	 *需求编号：【2019D1204】（马上账务文件同步分页处理）
	 *问题编号：【2019D1204】（马上账务文件同步分页处理）
	 *开发人员：【ludayong】
	 *创建日期：【2019/11/27 11:31】
	 *功能描述：分页查询马上还款明细临时表信息
	 *修改日期：【2019/11/27 11:31】
	 *修改描述：
	 */
	@Override
	public List<GzBankRepayDetailFileTempVO> queryByPage(GzBankRepayDetailFileTempVO gzBankRepayDetailFileTempVO) {
		String msg1 = "分页查询还款明细临时表";
		logger.debug(msg1, "message {}");
		List<GzBankRepayDetailFileTempVO> list = null;
		try {
			List<GzBankRepayDetailFileTemp> gzBankRepayDetailFileTemps = gzBankRepayDetailFileTempDao.queryByPage(gzBankRepayDetailFileTempVO);
			list = (List<GzBankRepayDetailFileTempVO>) beansCopy(gzBankRepayDetailFileTemps, GzBankRepayDetailFileTempVO.class);
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		if(list != null) {
			String msg2 = "查询的数据为大小为 " + list.size();
			logger.debug(msg2, "message {}");
		}
		return list;
	}

	/**
	 *需求编号：【2019D1204】（马上账务文件同步分页处理）
	 *问题编号：【2019D1204】（马上账务文件同步分页处理）
	 *开发人员：【ludayong】
	 *创建日期：【2019/11/27 11:31】
	 *功能描述：统计马上还款明细临时表数据量
	 *修改日期：【2019/11/27 11:31】
	 *修改描述：
	 */
	@Override
	public int queryCount() {
		String msg1 = "查询【还款明细临时表】表中数据量大小";
		logger.debug(msg1, "message {}");
		int num = 0;
		try {
			num = gzBankRepayDetailFileTempDao.queryCount();
		} catch (Exception e) {
			String msg2 = "查询【还款明细临时表】表中数据量大小出错" + e;
			logger.debug(msg2, "message {}");
			num = -1;
		}
		return num;
	}

}
